package skewreduce.framework.planner.search;

import org.apache.hadoop.conf.Configuration;

import skewreduce.framework.planner.PartitionNode;


public class PerfectBinaryTree extends SearchStrategy {

	int heightLimit;
	
	@Override
	public boolean shouldPartition(PartitionNode parent, PartitionNode l,
			PartitionNode r, boolean force) {
		return parent.getOpID().getLevel() < heightLimit;
	}

	@Override
	public Configuration getConf() {
		return null;
	}

	@Override
	public void setConf(Configuration conf) {
		heightLimit = conf.getInt("skewreduce.planner.search.perfectBinaryTree.height",0);
		if ( heightLimit == 0 )
			throw new IllegalArgumentException("skewreduce.planner.search.perfectBinaryTree.height must be > 0");
	}
}
